import request from "@/utils/request"
const BASE_URL = process.env.VUE_APP_BASE_URL_CRM

/**
 * 活动列表
 * @param {*} data
 */
export function crmMarketingIndexAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/queryPageList",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 活动创建
 * @param {*} data
 */
export function crmMarketingSaveAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/add",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 活动编辑
 * @param {*} data
 */
export function crmMarketingUpdateAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/update",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 活动删除
 * @param {*} data
 */
export function crmMarketingDeleteAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/deleteByIds",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 删除推广信息
 * @param {*} data
 */
export function crmMarketingDeleteDataAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/deleteData",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 活动详情
 * @param {*} data
 */
export function crmMarketingReadAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/queryById",
		method: "post",
		data: data
	})
}

/**
 * 活动统计
 * @param {*} data
 */
export function crmMarketingCensusAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/census",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 活动启用/禁用
 * @param {*} data
 */
export function crmMarketingIsEnableAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/updateStatus",
		method: "post",
		data: data
	})
}

/**
 * 同步数据
 * @param {*} data
 */
export function crmMarketingSynchroAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/syncData",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 导出
 * @param {*} data
 */
export function crmMarketingExcelExportAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/customerExportExcel",
		method: "post",
		data: data,
		responseType: "blob"
	})
}
/**
 * 详情
 * @param {*} data
 */
export function crmMarketingInformationAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/information",
		method: "post",
		data: data
	})
}

/**
 * 导入
 * @param {*} data
 *
 */
export function crmMarketingExcelImportAPI(data) {
	var param = new FormData()
	Object.keys(data).forEach(key => {
		param.append(key, data[key])
	})
	return request({
		url: BASE_URL + "crmMarketing/uploadExcel",
		method: "post",
		data: param,
		headers: {
			"Content-Type": "multipart/form-data"
		}
	})
}

/**
 * 导入模板下载
 * @param {*} data
 *
 */
export const crmMarketingExcelDownloadURL =
	process.env.VUE_APP_BASE_API + "crmMarketing/downloadExcel"
export function crmMarketingDownloadExcelAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/downloadExcel",
		method: "post",
		data: data,
		responseType: "blob"
	})
}

/**
 * @description: 批量导出
 * @param {*} data
 * @return {*}
 */
export function crmMarketingExcelAllExportAPI(data) {
	return request({
		url: BASE_URL + "crmMarketing/allExportExcel",
		method: "post",
		data: data,
		responseType: "blob",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}
